/// Section Begin  - Popup and Related Topic (JavaScript 1.0)
// eHelp® Corporation Dynamic HTML JavaScript 
// Copyright© 1998-2000 eHelp® Corporation.All rights reserved.
// Version=4.45

// Warning:Do not modify this file.It is generated by RoboHELP® and changes will be overwritten.



//Begin to support previous popup functions
//////////////////////////////////////////////////////////////////////////////////////////////
//
//	Begin DHTML Popup Functions
//
//////////////////////////////////////////////////////////////////////////////////////////////
//variables used to isolate the browser type
var gBsDoc			= null;			
var gBsSty			= null;
var gBsHtm			= null;
var gBsStyVisShow	= null;
var gBsStyVisHide	= null;
var gBsClientWidth	= 640;
var gBsClientHeight = 480;
var gBsBrowser		= null;

// here is the varible for judge popup windows size. these parameter is for IE5.0, it may need adjust for others.
var gBRateH_W		= 0.618; // 1.618 Golden cut.
var gBMaxXOfParent	= 0.8; 
var gBMaxYOfParent	= 0.8;
var gBscrollHeight   = 16;
var gBscrollWidth   =  16;
var gBpermitXDelta	= 3;
var gBpermitYDelta	= 3;


var arrayPopupURL = new Array();
var arrayAbsPopupURL = new Array();

var arrayDirty = new Array();

function setAbsPopupURL(nIndex, strURL)
{
	arrayAbsPopupURL[nIndex] = strURL;
}

function getAbsPopupURL(nIndex)
{
	if (nIndex == -1 || arrayAbsPopupURL.length <= nIndex) return null;
	else 
		return arrayAbsPopupURL[nIndex];
}

function getPopupURL(nIndex)
{
	if (nIndex == -1 || arrayPopupURL.length <= nIndex) return null;
	else 
		return arrayPopupURL[nIndex];
}

function getPopupID(nIndex)
{
	return gstrPopupID + nIndex;
}

function getPopupShadowID(nIndex)
{
	return gstrPopupShadowID + nIndex;
}

function getPopupTopicID(nIndex)
{
	return gstrPopupTopicID + nIndex;
}

function getPopupIFrameID(nIndex)
{
	return gstrPopupIFrameID + nIndex;
}

function getPopupIFrameName(nIndex)
{
	return gstrPopupIFrameName + nIndex;
}


function getPopupTopicStyle(nIndex)
{
	return eval("document.all['" + getPopupTopicID(nIndex) + "']").style;
}

function getPopupShadowStyle(nIndex)
{
	return eval("document.all['" + getPopupShadowID(nIndex) + "']").style;
}

function getPopupIFrame(nIndex)
{

	return eval("document.frames['" + getPopupIFrameName(nIndex) + "']");
}

function getPopupDivStyle(nIndex)
{
	return eval("document.all['" + getPopupID(nIndex) + "']").style;
}

function getPopupIFrameStyle(nIndex)
{
	return eval("document.all['" + getPopupIFrameName(nIndex) + "'].style");
}


function findDiv(strURL)
{
	var i = 0;
	for (i = 0; i < arrayPopupURL.length; i ++ ) {
		if (arrayPopupURL[i] == strURL) {
			return i;
		}
	}
	return -1;
}

var gnToken = -1;
function takeToken()
{
	gnToken ++;
	if (gnToken > 10000) gnToken = 0;
	return gnToken;
}

function IsValidToken(nToken)
{
	return (gnToken == nToken);
}

function addDiv(strURL)
{
	var i = 0; 
	for (i = 0; i < arrayPopupURL.length; i ++) {
		if (arrayPopupURL[i] == null) {
			arrayPopupURL[i] = strURL;
			return i;
		}
	}	
	arrayPopupURL[i] = strURL;
	arrayDirty[i] = true;
	return i;
}

function setDirty()
{
	var i = 0;
	for (i = 0; i < arrayPopupURL.length; i ++ )
		arrayDirty[i] = true;
}

function IsDirty(nIndex)
{
	if (nIndex == -1)
		return true;
	else 
		if (arrayDirty.length > nIndex) 
			return arrayDirty[nIndex];
		else
			return true;
}

function hideAll()
{
	var i = 0; 
	for (i = 0; i < arrayPopupURL.length; i ++ )
		getPopupDivStyle(i).visibility = gBsStyVisHide;
}

function getCurrentPopupIFrame()
{
	var i = 0;
	for (i = 0; i < arrayPopupURL.length; i ++)
		if (getPopupDivStyle(i).visibility == gBsStyVisShow)
			return getPopupIFrame(i);
	return null;
}

function setClear(nIndex)
{
	if (nIndex != -1)
		arrayDirty[nIndex] = false;
}

function _BSSCCreatePopupDiv(strURL)
{
	var nIndex = findDiv(strURL);
	if (nIndex == -1 ) {
		nIndex = addDiv(strURL);
		BsPopup_CreateDiv(nIndex);
	}
	else {
		if (IsDirty(nIndex)) {
			if("object" == typeof(getPopupIFrame(nIndex).document))
				getPopupIFrame(nIndex).document.location.href = strURL;
		}
	}
	return nIndex;

}

//the browser information itself
function _BSPSBrowserItself()
{
	var agent  = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns    = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
	this.ns2   = ((this.ns) && (this.major == 2));
	this.ns3   = ((this.ns) && (this.major == 3));
	this.ns4   = ((this.ns) && (this.major >= 4));
	this.ie	   = (agent.indexOf("msie") != -1);
	this.ie3   = ((this.ie) && (this.major == 2));
	this.ie4   = ((this.ie) && (this.major >= 4));
	this.op3   = (agent.indexOf("opera") != -1);

	if (this.ns4)
	{
		gBsDoc		= "document";
		gBsSty		= "";
		gBsHtm		= ".document";
		gBsStyVisShow	= "show";
		gBsStyVisHide	= "hide";

	}
	else if (this.ie4)
	{
		gBsDoc		 = "document.all";
		gBsSty 		= ".style";
		gBsHtm 		= "";
		gBsStyVisShow	= "visible";
		gBsStyVisHide	= "hidden";
	}
}

//Here is the browser type 
function _BSPSGetBrowserInfo()
{
	gBsBrowser	= new _BSPSBrowserItself();
}

//Get client size info
function _BSPSGetClientSize()
{
	if (gBsBrowser.ns4)
	{
		gBsClientWidth	= innerWidth;
		gBsClientHeight = innerHeight;

	}
	else if (gBsBrowser.ie4)
	{
		gBsClientWidth	= document.body.clientWidth;
		gBsClientHeight = document.body.clientHeight;
	}
}


var gstrPopupID = 'BSSCPopup';
var gstrPopupShadowID = 'BSSCPopupShadow';
var gstrPopupTopicID = 'BSSCPopupTopic';
var gstrPopupIFrameID = 'BSSCPopupIFrame';
var gstrPopupIFrameName = 'BSSCPopupIFrameName';

var gstrPopupSecondWindowName = 'BSSCPopup';

var gPopupWindow = null;
var gnPopupClickX = 0;
var gnPopupClickY = 0;

var gnPopupScreenClickX = 0;
var gnPopupScreenClickY = 0;

var gbPopupTimeoutExpired = false;


function DHTMLPopupSupport()
{
	if ((gbBsIE4) && (!gbBsMac)) {
		return true;
	}
	return false;
}



function BSSCPopup_IsPopup()
{
	if (DHTMLPopupSupport() && (this.name.indexOf(gstrPopupIFrameName) != -1)) {
		return true;
	} else if ((gbBsNS4 || gbBsIE4) && (this.name.indexOf(gstrPopupID) != -1)) {
		return true;
	} else {
		return false;
	}
}


// If there is a hyperlink in a popup window, display the hyperlink in
// the original window.
if (BSSCPopup_IsPopup() && !gbBsIE4) {
	document.write("<base target=\"_parent\">");
}

// Local functions.
function BsPopup_CreateDiv(nIndex)
{
	if(!DHTMLPopupSupport())
		return;
	// DO NOT SET Width and height for the div, otherwize it will make IE4 popup do not work when view the topic alone.
	var strPopupDiv = "<DIV ID='" + getPopupID(nIndex) + "' STYLE='position:absolute; top:-100; left:0; z-index:600; visibility:hidden;'>";
	strPopupDiv += "<DIV ID='" + getPopupShadowID(nIndex) + "' STYLE=\"position:absolute;top:0; left:0;  background-color:#C0C0C0;\"></DIV>";
	strPopupDiv += "<DIV ID='" + getPopupTopicID(nIndex) + "' STYLE=\"position:absolute;top:0; left:0;  background-color:#FFFFFF;border:1px #000000 outset;\">";
	strPopupDiv += "<IFRAME ID='" + getPopupIFrameID(nIndex) + "' name='" + getPopupIFrameName(nIndex) + "' src = '" + getPopupURL(nIndex) + "' frameborder=0 scrolling=auto></IFRAME>";
	strPopupDiv += "</DIV></DIV>";

	var objBody = document.all.tags("BODY")[0];
	if( typeof(objBody) != "object" )
		return;

	objBody.insertAdjacentHTML("beforeEnd", strPopupDiv);
}

function BSSCPopup_Timeout(nIndex, nToken)
{
    if (!IsValidToken(nToken)) return;

	if ((getPopupIFrame(nIndex).document.readyState == "complete") &&
		(getPopupIFrame(nIndex).document.body != null)) {
		window.getPopupDivStyle(nIndex).visibility = gBsStyVisShow;
		setClear(nIndex);
		window.gbPopupTimeoutExpired = true;

		BSSCPopup_ChangeTargettoParent(getPopupIFrame(nIndex).document);
		getPopupIFrame(nIndex).document.body.onclick = BSSCPopupClicked;

		if (gbOrignalOnMouseDown == null)
			gbOrignalOnMouseDown = document.onmousedown;

		document.onmousedown = BSSCPopupParentClicked;

	} else {
		setTimeout("BSSCPopup_Timeout(" + nIndex + "," + nToken + ")", 100);
	}
}


// VH 08/10/00 
// do not change target to parent if the href is using javascript
function BSSCPopup_ChangeTargettoParent(tagsObject)
{
	var collA = tagsObject.all.tags("A");
	BSSCPopup_ChangeTargettoParent2(collA);

	var collIMG = tagsObject.all.tags("IMG");
	BSSCPopup_ChangeTargettoParent2(collIMG);
}

function BSSCPopup_ChangeTargettoParent2(colls)
{
	var j = 0;
	if (colls != null)  {
		for (j = 0; j < colls.length; j ++ )
		{
			var strtemp = colls[j].href;
			strtemp = strtemp.toLowerCase();
			if (strtemp.indexOf("javascript:") == -1)
				colls[j].target = "_parent";
		}

	}
}

function BSPSPopupTopicWinHelp(strURL)
{
	_BSSCPopup(strURL);
	return;
}

function _BSSCPopup(strURL, width, height)
{
	var cuswidth = 0;
	var cusheight = 0;
	if ("undefined" != typeof(width) && "undefined" != typeof(height)) {
		cuswidth = width;
		cusheight= height;
	}
	
	if (DHTMLPopupSupport()) {
		// If we are already in a popup, replace the contents
	//	if (BSSCPopup_IsPopup()) {
	//		parent._BSSCPopup(strURL, cuswidth, cusheight);
	//	} else {
			var nToken = takeToken(); // take  token first.
			var nIndex = _BSSCCreatePopupDiv(strURL);
			window.gbPopupTimeoutExpired = false;
			var ntWidth = gBsClientWidth;
			var ntHeight = gBsClientHeight;
			_BSPSGetClientSize();
			if (ntWidth != gBsClientWidth || ntHeight != gBsClientHeight) {
				setDirty();
			}


			if (IsDirty(nIndex)) {
				if (gbBsMac) {
					setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight  +")", 400);
				} else {
					setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight + ")", 100);
				}
			}
			else {
				MoveDivAndShow(nIndex ,nToken, cuswidth, cusheight);
			}
	//	}

	} else {
		_BSSCPopup2(strURL, cuswidth, cusheight);
	}
	return;
}


function _BSSCPopup2(strURL, width, height)
{
	if (window.name == gstrPopupSecondWindowName) {
		window.location = strURL;
	} else {
		if (!gbBsMac || !gBsBrowser.ns4) {
			BSSCHidePopupWindow();
		}
		var nX = 0;
		var nY = 0;
		var nHeight = 300;
		var nWidth = 400;
		if (width > 0 && height > 0) {
			nHeight = height;
			nWidth = width;
		}
		_BSPSGetClientSize();

		nX = window.gnPopupScreenClickX;
		nY = window.gnPopupScreenClickY;

		if (nY + nHeight + 40 > screen.availHeight) {
			nY = screen.availHeight - nHeight - 40;
		}
		if (nX + nWidth + 40 > screen.availWidth) {
			nX = screen.availWidth - nWidth - 40;
		}
		// Launch a separate window
		var strParam = "titlebar=no,toolbar=no,status=no,location=no,menubar=no,resizable=yes,scrollbars=yes";
		if (gBsBrowser.ns) {
			strParam += ",OuterHeight=" + nHeight + ",OuterWidth=" + nWidth;
			strParam += ",screenX=" + nX + ",screenY=" + nY;
			strParam += ",dependent=yes";
		}
		else {
			strParam += ",height=" + nHeight + ",width=" + nWidth;
			strParam += ",left=" + nX + ",top=" + nY;
		}
		window.gPopupWindow = window.open(strURL, gstrPopupSecondWindowName, strParam);
		if (gBsBrowser.ns4) {
			window.gPopupWindow.captureEvents(Event.CLICK | Event.BLUE);
			window.gPopupWindow.onclick = NonIEPopup_HandleClick;
			window.gPopupWindow.onblur = NonIEPopup_HandleBlur;
		}
		else if (gBsBrowser.ie4)
		{
			setTimeout("setPopupFocus();", 100);
		}
	}
	return;
}

function setPopupFocus()
{
	window.gPopupWindow.focus();
}

function NonIEPopup_HandleBlur(e)
{
	window.gPopupWindow.focus();
}

function NonIEPopup_HandleClick(e)
{
	// Because navigator will give the event to the handler before the hyperlink, let's
	// first route the event to see if we are clicking on a Popup menu in a popup.
	document.routeEvent(e);

	// If a popup menu is active then don't do anything with the click
	if (window.gPopupWindow.gbInPopupMenu) {
		window.gPopupWindow.captureEvents(Event.CLICK);
		window.gPopupWindow.onclick = NonIEPopup_HandleClick;
		return false;
	}

	// Close the popup window
	if (e.target.href != null) {
		window.location.href = e.target.href;
		if (e.target.href.indexOf("javascript:void(0)") == -1 && e.target.href.indexOf("javascript:null") == -1 && e.target.href.indexOf("BsscPopup") == -1) {
			this.close();
		}
	} else {
		this.close();
	}
	return false;

}

function BSSCPopup_AfterLoad(nIndex, nToken, cuswidth, cusheight)
{	
	if (typeof(window.getPopupIFrame(nIndex).document) == "unknown") {
		_BSSCPopup2(getPopupURL(nIndex), cuswidth, cusheight);
		return;
	}
    if (!IsValidToken(nToken)) return;

	if ((window.getPopupIFrame(nIndex).document.readyState == "complete") &&
		(window.getPopupIFrame(nIndex).document.body != null)) {
			if (window.getPopupIFrame(nIndex).document.location.href.indexOf("about:blank") != -1) { // add this check. IE will use about:blank" as the default vaule for Iframe.
				window.getPopupIFrame(nIndex).document.location = getPopupURL(nIndex);
				setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight + ")", 200);
			}
			else
				{
					setAbsPopupURL(nIndex, window.getPopupIFrame(nIndex).document.location.href); // change URL to abs url.
					BSSCPopup_ResizeAfterLoad(nIndex, nToken, cuswidth, cusheight);
				}
	} else {
		setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight + ")", 200);
	}
}


function BSSCPopup_ResizeAfterLoad(nIndex, nToken, cuswidth, cusheight)
{
	if (window.gbPopupTimeoutExpired) return;

    if (!IsValidToken(nToken)) return;

	getPopupDivStyle(nIndex).visibility = gBsStyVisHide;

	// Determine the width and height for the window
	//var size = new BSSCSize(0, 0);
	//BSSCGetContentSize(window.getPopupIFrame(nIndex), size);
	//var nWidth = size.x;
	//var nHeight = size.y;

	_BSPSGetClientSize();
	
	var size = new BSSCSize(0, 0);

	if (cuswidth <= 0 || cusheight <= 0)
		BSSCGetContentSize(window.getPopupIFrame(nIndex), size);
	else {
		size.x = cuswidth;
		size.y = cusheight;
	}

	// Determine the width and height for the window
	var nWidth = size.x;
	var nHeight = size.y;
		
	if (nWidth < 40 || nHeight < 40) return;  // there must be something terribly wrong.

	window.getPopupDivStyle(nIndex).pixelWidth = nWidth;
	window.getPopupDivStyle(nIndex).pixelHeight = nHeight;

	window.getPopupShadowStyle(nIndex).pixelWidth = nWidth;
	window.getPopupShadowStyle(nIndex).pixelHeight = nHeight;
	window.getPopupTopicStyle(nIndex).pixelWidth = nWidth;
	window.getPopupTopicStyle(nIndex).pixelHeight = nHeight;
	if (gbBsIE55)
	{
		window.getPopupShadowStyle(nIndex).pixelWidth = nWidth + 2;
		window.getPopupShadowStyle(nIndex).pixelHeight = nHeight + 2;
		window.getPopupTopicStyle(nIndex).pixelWidth = nWidth + 2;
		window.getPopupTopicStyle(nIndex).pixelHeight = nHeight + 2;
	}

	window.getPopupIFrameStyle(nIndex).pixelWidth = nWidth;
	window.getPopupIFrameStyle(nIndex).pixelHeight = nHeight;
	if (gbBsIE55)
	{
		window.getPopupIFrameStyle(nIndex).top = 0;
		window.getPopupIFrameStyle(nIndex).left = 0;
	}
	
	var strURL = getPopupURL(nIndex);
	if (strURL.indexOf("#") != -1)
		getPopupIFrame(nIndex).location.href = strURL;  // reload again, this will fix the bookmark misunderstand in IE5.
		
	MoveDivAndShow(nIndex, nToken, cuswidth, cusheight);
}

function MoveDivAndShow(nIndex, nToken, cuswidth, cusheight)
{
	if (window.getPopupIFrame(nIndex).document.location.href != getAbsPopupURL(nIndex)) { // if redirect, reload again.
			window.getPopupIFrame(nIndex).document.location = getPopupURL(nIndex);
			setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight + ")", 200);
			return;
	}

	// Determine the position of the window
	var nClickX = window.gnPopupClickX;
	var nClickY = window.gnPopupClickY;
	var nTop = 0;
	var nLeft = 0;

	var nWidth = window.getPopupDivStyle(nIndex).pixelWidth;
	var nHeight = window.getPopupDivStyle(nIndex).pixelHeight;

	if (nClickY + nHeight + 20 < gBsClientHeight + document.body.scrollTop) {
		nTop = nClickY + 10;
	} else {
		nTop = (document.body.scrollTop + gBsClientHeight) - nHeight - 20;
	}
	if (nClickX + nWidth < gBsClientWidth + document.body.scrollLeft) {
		nLeft = nClickX;
	} else {
		nLeft = (document.body.scrollLeft + gBsClientWidth) - nWidth - 8;
	}
	
	if (nTop < document.body.scrollTop ) nTop  = document.body.scrollTop + 1;
	if (nLeft< document.body.scrollLeft) nLeft = document.body.scrollLeft + 1;


	window.getPopupDivStyle(nIndex).left = nLeft;
	window.getPopupDivStyle(nIndex).top = nTop;

	// Set the location of the background blocks
	window.getPopupShadowStyle(nIndex).left = 6;
	window.getPopupShadowStyle(nIndex).top = 6;
	if (gbBsIE55)
	{
		window.getPopupShadowStyle(nIndex).left = 4;
		window.getPopupShadowStyle(nIndex).top = 4;
	}

	if (gbBsMac) {
		// Total hack on the iMac to get the IFrame to position properly
		window.getPopupIFrameStyle(nIndex).pixelLeft = 100;
		window.getPopupIFrameStyle(nIndex).pixelLeft = 0;
		// Explicitly call BSSCOnLoad because the Mac doesn't seem to do it
		window.getPopupIFrame(nIndex).window.BSSCOnLoad();
	}

	BSSCPopup_Timeout(nIndex , nToken );
	
	return;
}

function	BSSCSize(x, y)
{
	this.x = x;
	this.y = y;
}

function BSSCGetContentSize(thisWindow, size)
{
	if (!((gBsBrowser.ie4) || (gBsBrowser.ns4)))
		return;

	if (gbBsMac) {
		size.x = 300;
		size.y = 300;
		return;
	}

	// Resize the width until it is wide enough to handle the content
	// The trick is to start wide and determine when the scrollHeight changes
	// because then we know a scrollbar is necessary. We can then go back
	// to the next widest size (for no scrollbar)

	var ClientRate = gBsClientHeight / gBsClientWidth;

	var GoldenSize = new BSSCSize(0,0);
	GoldenSize.x = gBsClientWidth * gBMaxXOfParent;
	GoldenSize.y = gBsClientHeight *gBMaxYOfParent ;

	if (ClientRate > gBRateH_W) {
		GoldenSize.y = GoldenSize.x * gBRateH_W;
	}
	else {
		GoldenSize.x = GoldenSize.y / gBRateH_W;
	}

	// Try to using parent specified max x.
	var x = 0;
	var maxgoldx = GoldenSize.x;
	var maxx = gBsClientWidth * gBMaxXOfParent;
	
	// This double resize causes the document to re-render (and we need it to)
	thisWindow.moveTo(10000,10000); // this is used to fix the flash on IE4.
	thisWindow.resizeTo(1, 1);
	thisWindow.resizeTo(1, 1);
	thisWindow.resizeTo(maxgoldx, thisWindow.document.body.scrollHeight + gBscrollHeight);
	thisWindow.resizeTo(maxgoldx, thisWindow.document.body.scrollHeight + gBscrollHeight);
		
	var miny = thisWindow.document.body.scrollHeight + gBscrollHeight;
	
	if (miny > GoldenSize.y) // the popup does not fix in the parent wanted golden area. so try to expand itself as large as it can
	{
		thisWindow.resizeTo(maxx , thisWindow.document.body.scrollHeight + gBscrollHeight);
		thisWindow.resizeTo(maxx , thisWindow.document.body.scrollHeight + gBscrollHeight);
		
		miny = 	thisWindow.document.body.scrollHeight + gBscrollHeight;
		maxy = gBsClientHeight * gBMaxYOfParent;
		
		if (miny > maxy) { // the popup must have a scroll, OK let it be.
			miny = maxy;
			size.x = maxx;
			size.y = maxy;
			thisWindow.document.body.scroll = 'yes'; // At this time we do want to show scroll any more. so it will looks better a little.
		}
		else { // popup still can fit in the parent area by someway. now we choose the same h/w rate as parent.
			size.y = miny;
			
			//  downsize from maxx , now I try to using binary divide.
			x = maxx;
			deltax = -maxx/2;
			//j = 0;
			while (true) {
				x = x + deltax;
				thisWindow.resizeTo(x, miny);
				thisWindow.resizeTo(x, miny);
				diffy = thisWindow.document.body.scrollHeight + gBscrollHeight - x * ClientRate;
				if (diffy >  gBpermitYDelta ) // it is higher than wanted, so x need to be wide a little bitter
					deltax = Math.abs(deltax) /2;
				else if (diffy <  -gBpermitYDelta) // it is shorter than wanted, so x need to be narrow a little bitter
					deltax = -Math.abs(deltax) /2;
				else 
					// the y is close enough to wanted.
					break;
				if (Math.abs(deltax) < gBpermitXDelta) // the next change is too slight and it can be ignore.
					break;
			}
			size.x = thisWindow.document.body.scrollWidth; //+ gBscrollWidth;
			size.y = thisWindow.document.body.scrollHeight;// + gBscrollHeight;	
			thisWindow.document.body.scroll = 'no'; // At this time we do not want to show scroll any more. so it will looks better a little.
			
		// Handle absurd cases just in case IE flakes
	//		if (size.y < 100) {
	//			size.y = 100;
	//		}
		}
	}
	else {
		// VH 08/06/00 . OK there is another case we did not check before.
		if (thisWindow.document.body.scrollWidth > maxgoldx) {
			size.x = maxx; 
			size.y = miny;	
			thisWindow.document.body.scroll = 'yes'; // At this time we do want to show scroll any more. so it will looks better a little.
		}
		else {
			//  downsize from maxgoldx , now I try to using binary divide.
			x = maxgoldx;
			deltax = -maxgoldx/2;
			//i = 0;
			while (true) {
				x = x + deltax;
				thisWindow.resizeTo(x, miny);
				thisWindow.resizeTo(x, miny);
				diffy = thisWindow.document.body.scrollHeight + gBscrollHeight - x * gBRateH_W;
				if (diffy >  gBpermitYDelta ) // it is higher than wanted, so x need to be wide a little bitter
					deltax = Math.abs(deltax) /2;
				else if (diffy <  -gBpermitYDelta) // it is shorter than wanted, so x need to be narrow a little bitter
					deltax = -Math.abs(deltax) /2;
				else 
					// the y is close enough to wanted.
					break;
				if (Math.abs(deltax) < gBpermitXDelta) // the next change is too slight and it can be ignore.
					break;
				//i ++;
				
			}
			size.x = thisWindow.document.body.scrollWidth ;//+ gBscrollWidth;
			size.y = thisWindow.document.body.scrollHeight ;//+ gBscrollHeight;	
			thisWindow.document.body.scroll = 'no'; // At this time we do not want to show scroll any more. so it will looks better a little.
		}
	}
	
	// no reload no scrollbar.
	//size.x = size.x + 16;	 //reserve a width for scrollbar (IE 4.0 only)

	thisWindow.resizeTo(size.x, size.y);
	thisWindow.resizeTo(size.x, size.y);
	return;
}



function BSSCPopupParentClicked()
{
	if (!window.gbPopupTimeoutExpired) {
		return false;
	}
	
	document.onmousedown = gbOrignalOnMouseDown;

	// Simply hide the popup
	hideAll();

	window.gbPopupTimeoutExpired = false;

	return true;
}


function BSSCPopupClicked()
{
	if (!window.gbPopupTimeoutExpired) {
		return false;
	}


	var popupIFrame = getCurrentPopupIFrame();
	if (popupIFrame == null) {
		return true;
	}

/*
	if ("undefined" != typeof(popupIFrame.gbInPopupMenu) &&
		popupIFrame.gbInPopupMenu) {
		return true;
	}*/

	if (!((popupIFrame.window.event != null) &&
	    (popupIFrame.window.event.srcElement != null) &&
	    ((popupIFrame.window.event.srcElement.tagName == "A") ||
	    (popupIFrame.window.event.srcElement.tagName == "IMG")))) {
		document.onmousedown = gbOrignalOnMouseDown;

	// Simply hide the popup
		hideAll();

		window.gbPopupTimeoutExpired = false;

		return true;
	}
}


//trace the mouse over's position for hotspot
function  BSPSPopupOnMouseOver(event)
{
	if (gBsBrowser.ie4) {
		window.gnPopupClickX = event.clientX + document.body.scrollLeft;
		window.gnPopupClickY = event.clientY + document.body.scrollTop;
		window.gnPopupScreenClickX = event.screenX;
		window.gnPopupScreenClickY = event.screenY;
	} else if (gBsBrowser.ns4) {
		window.gnPopupClickX = event.pageX - window.pageXOffset;
		window.gnPopupClickY = event.pageY - window.pageYOffset;
		window.gnPopupScreenClickX = event.screenX - window.pageXOffset;
		window.gnPopupScreenClickY = event.screenY - window.pageYOffset;
	}
}


function BSSCHidePopupWindow()
{
	if (window.gPopupWindow != null) {
		if (gBsBrowser.ns4) {
			if ((typeof window.gPopupWindow != "undefined") && (!window.gPopupWindow.closed)) {
				window.gPopupWindow.close();
				window.gPopupWindow = null;
			}
		}
	}

	return;
}

// Add the PopupOnClick to the onclick array.
if (typeof(BsscRegisterOnClick) != "undefined")
{
	BsscRegisterOnClick(BsPopupOnClick);
}
//End to support previous popup functions

//Begin to support previous relative topics
//If webHelp needs Related Topics DHTMLcode, it's supposed to add it here
var gbPopupMenuTimeoutExpired = false;
var gbInPopupMenu = false;
var gbPopupMenuTopicList = null;

//////////////////////////////////////////////////////////////////////////////////////////
//
// Popup Menu code
//
//////////////////////////////////////////////////////////////////////////////////////////

var g_bIsPopupMenuInit = false;
function _WritePopupMenuLayer()
{
	if (!g_bIsPopupMenuInit)
        {
	  if (gbBsNS4) {
//Do not try to write ininle styles for NS!  NS can not handle it and will not stop downloading the html page...
	   document.write("<DIV CLASS='WebHelpPopupMenu' ID='PopupMenu'></DIV>");
	  } else{
	  document.write("<DIV ID='PopupMenu' STYLE='position:absolute; left:0px; top:0px; z-index:4; visibility:hidden;'></DIV>");
	  if (gbBsIE4) {
		document.write("<STYLE TYPE='text/css'>");
		if (gbBsMac) {
			document.write(".PopupOver {font-family:'Arial'; color:white; background:navy; font-size:10pt; text-decoration:none;}");
			document.write(".PopupNotOver {font-family:'Arial'; color:black; background:#c0c0c0; font-size:10pt; text-decoration:none;}");
		} else {
			document.write(".PopupOver {font-family:'Arial'; color:white; background:navy; font-size:8pt; text-decoration:none;}");
			document.write(".PopupNotOver {font-family:'Arial'; color:black; background:#c0c0c0; font-size:8pt; text-decoration:none;}");
		}
		document.write("</STYLE>");
	   }
          }
	  g_bIsPopupMenuInit = true;
	}
}

//Define variable arguments as: strTitle, strUrl
function MTE() 
{
	this.strTitle = MTE.arguments[0];
	if (MTE.arguments.length > 1)
		this.strURL = MTE.arguments[1];
	else
		this.strURL = this.strTitle;
}

// If the topic list is set, it is an array of TopicEntry objects (defined in WebHelp3.js)
function PopupMenu_SetTopicList(aPopupTopicArray)
{
	gbPopupMenuTopicList = aPopupTopicArray;
}

//Seek for the bsscright frame 
function _SeekFrameByName( cRoot, strName )
{
	if( cRoot == null )	return null;
	if( cRoot.frames == null )	return null;
	if( cRoot.frames[strName] != null )	return cRoot.frames[strName];
	for (var i=0; i<cRoot.frames.length; i++)
	{
		var cObj = _SeekFrameByName( cRoot.frames(i).document, strName );
		if( cObj != null )		return cObj;
	};
	return null;
}
function _GetFrameByName( cRoot, strName )
{
	if( cRoot == null )	return null;
	var cRet = _SeekFrameByName(cRoot, strName);
	if( cRet != null )	return cRet;
	if (cRoot.parent != cRoot)
		return _GetFrameByName( cRoot.parent, strName );
	else
		return null;
}

//var gbOriPopupMenuClick = null;

function _PopupMenu_Invoke(fn_arguments)
{
	// Make sure we have reasonable arguments
	var argLen = fn_arguments.length;
	if (argLen < 3) {
		return false;
	}

	// Check to see if we only have one target
	var strTarget = "";
	var targetDoc = null;
	if (fn_arguments[1] == '') {
		if (BSSCPopup_IsPopup()) {
			targetDoc = parent;
			strTarget = "TARGET= _parent";
		}
		else
			targetDoc = window.document;
	} else {
		targetDoc = _GetFrameByName( parent, fn_arguments[1] );

		strTarget = "TARGET='" + fn_arguments[1] + "'";
	}

	if ((!gbBsIE4 && !gbBsNS4) || ((gbBsMac) && (gbBsIE4) && (window.event.srcElement.tagName == "AREA"))) {
	
		var argLen 	= fn_arguments.length;

		// Create the window that the hyperlinks will go into
		var nHeight = argLen * 15;
		var nWidth = 400;
		var strParam = "titlebar=no,toolbar=no,status=no,location=no,menubar=no,resizable=yes,scrollbars=auto";
		strParam += ",height=" + nHeight + ",width=200";
		strParam += ",resizable";

		// Create a temporary window first to ensure the real popup comes up on top
		var wndTemp = window.open("", "temp", strParam);

		// Create the real popup window
		var wndPopupLinks = window.open("", "popuplinks", strParam);

		// Close the temporary
		wndTemp.close();

		wndPopupLinks.document.open("text/html");
		wndPopupLinks.document.write("<html><head></head>");
		wndPopupLinks.document.write("<body onBlur=\'self.focus();\'>");
		var strParaLine = "";
		for (var i = 0; i < (argLen - 2) / 2; i++) {
			strParaLine = "";
			strParaLine += "<a href=\"javascript:";
			if (gbBsIE) {
				strParaLine += "onBlur=null; ";
			}
			strParaLine += "opener.location=\'";
			strParaLine += fn_arguments[2 * i + 3];
			strParaLine += "\';close();\"";
			strParaLine += strTarget;

			strParaLine += ">";
			strParaLine += fn_arguments[2 * i + 2];
			strParaLine += "</a>";
			strParaLine += "<br>";
			wndPopupLinks.document.write(strParaLine);
		}
		wndPopupLinks.document.write("</body></html>");
		wndPopupLinks.document.close();
		window.gbInPopupMenu = true;
		if (!gbBsIE) {
			wndPopupLinks.focus();
		}

		return false;
	}


	if (((argLen < 5) && ((isNaN(fn_arguments[2])) || (gbPopupMenuTopicList == null))) ||
		((argLen < 4) && ((!isNaN(fn_arguments[2])) && (gbPopupMenuTopicList != null)))) {
		// Get the place that we will be putting the topic into
		var strURL = "";
		if (isNaN(fn_arguments[2]) ||  (gbPopupMenuTopicList == null)) {
			strURL = fn_arguments[3];
		}
		else 	{
			strURL = gbPopupMenuTopicList[fn_arguments[2]].strURL;
		}

		if (targetDoc != null) {
			targetDoc.location.href = strURL;
		}
		else {
			window.open(strURL);
		}		
		window.gbInPopupMenu = true;
		return false;
	}
	
	var strMenu = "";
	if (gbBsNS4) {
		strMenu = '<TABLE BORDER="1" CELLSPACING=0 CELLPADDING=3 BGCOLOR="#c0c0c0">';
	} else {
		strMenu = '<TABLE STYLE="border:2px outset white;" CELLSPACING=0';
		if (gbBsMac) {
			strMenu += ' CELLPADDING=4';
		} else {
			strMenu += ' CELLPADDING=2';
		}	
		strMenu += ' BGCOLOR=#c0c0c0>';
	}
	// Add each of the items
	var i = 2;
	while (i <= argLen - 1) {
		strMenu += '<TR><TD><NOBR>'
		// If the destination is a number then look it up in the topic list
		if (isNaN(fn_arguments[i]) ||  (gbPopupMenuTopicList == null)) {
			strMenu += '<DIV STYLE="padding-left:3pt; padding-right:3pt;"><A HREF="' + fn_arguments[i + 1] + '"' + strTarget;
		} else {
			strMenu += '<DIV STYLE="padding-left:3pt; padding-right:3pt;"><A HREF="' + gbPopupMenuTopicList[fn_arguments[i]].strURL + '"' + strTarget;
		}
		strMenu += ' onclick="PopupMenu_HandleClick(event);"';
		strMenu += ' onmouseover="PopupMenu_Over(event);"';
		strMenu += ' onmouseout="PopupMenu_Out(event);"';
		strMenu += '>';
		if (isNaN(fn_arguments[i]) || (gbPopupMenuTopicList == null)) {
			strMenu += '<SPAN CLASS="PopupNotOver">' + fn_arguments[i] + '</SPAN>';
		} else {
			strMenu += '<SPAN CLASS="PopupNotOver">' + gbPopupMenuTopicList[fn_arguments[i]].strTitle + '</SPAN>';
		}
		strMenu += '</A></DIV></NOBR></TD></TR>';

		if (isNaN(fn_arguments[i]) || (gbPopupMenuTopicList == null)) {
			i += 2;
		} else {
			i += 1;
		}
	}
	strMenu += "</TABLE>";

	if (gbBsMac) {
	// totally hack. because ie5 in mac need something. </TABLE> is one of them. mac is mad.
		strMenu +="<TABLE></TABLE>";
	}

	var layerPopup = null;
	var stylePopup = null;
	var nEventX = 0;
	var nEventY = 0;
	var nWindowWidth = 0;
	if (gbBsIE4) {

		layerPopup = document.all["PopupMenu"];
		layerPopup.innerHTML = strMenu;
		stylePopup = layerPopup.style;

		_BSPSGetClientSize();

		// Get the position of the item causing the event (relative to its parent)
		nEventX = window.event.clientX;
		nEventY = window.event.clientY;

		if (nEventY + layerPopup.scrollHeight + 10 < gBsClientHeight) {
			nEventY += document.body.scrollTop + 10;
		} else {
			nEventY = (document.body.scrollTop + gBsClientHeight) - layerPopup.scrollHeight - 20;
		}
		stylePopup.top = nEventY;
		
		var nPopupWidth = layerPopup.scrollWidth;
		if (gbBsMac) {
			nPopupWidth = 80; // we have no idea how to get the dynamic width of the popup.
		}
		if (nEventX + nPopupWidth + 20 > gBsClientWidth) {
			if (gBsClientWidth - nPopupWidth < 5) {
				stylePopup.left = 5;
			} else {
				stylePopup.left = gBsClientWidth - nPopupWidth - 5;
			}
		} else {
			stylePopup.left = nEventX + document.body.scrollLeft + 20;
		}

		stylePopup.visibility = "visible";
		document.onclick = PopupMenu_HandleClick;
		
	} else if (gbBsNS4) {
		layerPopup = document.layers.PopupMenu;
		layerPopup.visibility = "hide";
		stylePopup = layerPopup.document;
		stylePopup.write(strMenu);
		stylePopup.close();
		var e = fn_arguments[0];
		nEventX = e.pageX;
		nEventY = e.pageY;
		_BSPSGetClientSize();
		if (nEventY + layerPopup.clip.height + 20 < window.pageYOffset + gBsClientHeight) {
			nEventY += 20;
		} else {
			nEventY = gBsClientHeight + window.pageYOffset- layerPopup.clip.height - 20;
		}
		layerPopup.top = nEventY;

		if (nEventX + layerPopup.clip.width + 20 > gBsClientWidth + window.pageXOffset) {
			if (gBsClientWidth + window.pageXOffset - layerPopup.clip.width < 20) {
				nEventX = 5;
			} else {
				nEventX = gBsClientWidth + window.pageXOffset - layerPopup.clip.width - 20;
			}
		} else {
			nEventX += 20;
		}

		layerPopup.left = nEventX;

		layerPopup.visibility = "show";

//		window.captureEvents(Event.CLICK | Event.MOUSEDOWN);
		window.captureEvents(Event.MOUSEDOWN);
//		window.onclick = PopupMenu_HandleClick;
		window.onmousedown = PopupMenu_HandleClick;
	}

	window.gbInPopupMenu = true;
	window.gbPopupMenuTimeoutExpired = false;
	setTimeout("PopupMenu_Timeout();", 100);
	return false;
}


function PopupMenu_Timeout()
{
	window.gbPopupMenuTimeoutExpired = true;
}

function PopupMenu_Over(e)
{
    if (gbBsIE4) {
		e.srcElement.className = "PopupOver";
    } else if (gbBsNS4) {
//		this.bgColor = "red";
//        e.target.document.className = "PopupOver";
    }
	return;
}

function PopupMenu_Out(e)
{
    if (gbBsIE4) {
		e.srcElement.className = "PopupNotOver";
    } else if (gbBsNS4) {
        this.bgColor = "#f0f0f0";
    }
	return;
}


function PopupMenu_HandleClick(e)
{
	if (!window.gbPopupMenuTimeoutExpired) {
		return;
	}

	window.gbInPopupMenu = false;

	if (gbBsNS4) {
//		window.releaseEvents(Event.CLICK);
		window.releaseEvents(Event.MOUSEDOWN);
	}

	var layerPopup = null;
	var stylePopup = null;
	if (gbBsIE4) {
		layerPopup = document.all["PopupMenu"];
		stylePopup = layerPopup.style;
		stylePopup.visibility = "hidden";
	} else if (gbBsNS4) {
		layerPopup = document.layers.PopupMenu;
		layerPopup.visibility = "hide";
	}

//	if (gbOriPopupMenuClick!= null)
//		document.onclick = gbOriPopupMenuClick;

	return;
}

// This function should be deleted when all old projects are cleaned up
function BSPSWritePopupFrameForIE4()
{
	return false;
}

/////////////////////////////////////////////////////////////////////
function BSSCPopup_ClickMac()
{
	if ((!DHTMLPopupSupport()) && (gbBsIE4))
	{	
		var bClickOnAnchor = false;
		var el;
		if ((window.event != null) &&
		    (window.event.srcElement != null))
		{
		    el = window.event.srcElement;
			while (el != null)
			{
				if ((el.tagName == "A") || (el.tagName == "AREA")) 	{
					bClickOnAnchor = true;
					break;
				}
				if (el.tagName == "BODY") {
					break;
				}
				el = el.parentElement;
			}
		}
		if (BSSCPopup_IsPopup())
		{
			if (!bClickOnAnchor) {
				parent.window.gPopupWindow = null;
				self.close();
			}
		}
		else
		{
			bClosePopupWindow = true;
			if ((bClickOnAnchor) &&
				(el.href) &&
			    ((el.href.indexOf("javascript:BSSCPopup") != -1) || (el.href.indexOf("javascript:null") != -1) || (el.href.indexOf("javascript:void(0)") != -1)))
			{
				bClosePopupWindow = false;
			}
			if (bClosePopupWindow)
			{
				if (window.gPopupWindow != null && !window.gPopupWindow.closed )
				{
					window.gPopupWindow.close();
				}
			}
		}
	}
 }

//////////////////////////////////////////////////////////////////////

_BSPSGetBrowserInfo();


function BsPopupOnClick()
{
	if (!gbBsIE4)
		return;

	BSSCPopup_ClickMac();
}

function _BSSCOnError(message)
{
	if(-1 != message.indexOf("denied") 
		|| -1 != message.indexOf("Object required"))
	 return true;
}

//End to support previous relative topics

/// Section End  - Popup and Related Topic (JavaScript 1.0)

